<?php
require "$sysroot/lib/3rdparty/cssminify.php";

class TdStylesheet extends TdComponent {
  var $name;
  var $value;
  var $minify = false;
  var $css = array();


  function __construct($id, $template="") {
    parent::__construct($id, $template);
  }

  function addCSS($css_file) {
    $this->css[] = $css_file;
  }

  /*
  function __toString() {
    global $webroot;
    echo $this->parent;
	return "<link href=\"".$webroot.$this->parent->classname."/".$classname."+getStyles\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />";
  }
  */
  
  function __toString() {
    header('Content-type: text/css');
    ob_start();
    foreach ($this->css as $style) {
      if (is_file($style)) {
        include($style);
      }
    }

    if ($this->minify) {
      return cssminify(ob_get_clean());
    }
    else {
      return ob_get_clean();
    }
  }

  function setMinify($value) {
    $this->minify = $value;
  }

  function getMinify() {
    return $this->minify;
  }
}

?>
